package org.qqcui.designpattern.principles.srp;

/**
 * 单一职责原则实现方式2
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2020-10-12 23:15
 **/
public class SingleResponsibility2 {

	public static void main(String[] args) {
		RoadVehicle roadVehicle = new RoadVehicle();
		roadVehicle.run("摩托车");
		roadVehicle.run("汽车");

		AirVehicle airVehicle = new AirVehicle();
		airVehicle.run("飞机");
	}
}

/**
 * 方式二，服务单一职责原则，但是需要修改类，花费的代价比较大，修改类的同时还需要修改客户端的调用方式
 */
class RoadVehicle {
	public void run(String vehicle) {
		System.out.println(vehicle + "在公路上运行……");
	}
}

class AirVehicle {
	public void run(String vehicle) {
		System.out.println(vehicle + "在空中运行……");
	}
}

class WaterVehicle {
	public void run(String vehicle) {
		System.out.println(vehicle + "在水中运行……");
	}
}